<?php

/**
 * MVM_MALL 网上商店系统 投票显示文件
 * ============================================================================
 * 版权所有 (C) 2007-2010 www.mvmmall.com，并保留所有权利。
 * 网站地址: http://www.mvmmall.com
 * ----------------------------------------------------------------------------
 * 这是一个免费开源的软件；这意味着您可以在不用于商业目的的前提下对程序代码
 * 进行修改、使用和再发布。
 * ============================================================================
 * $Author:  www.mvmmall.com  $
 * $Date: 2008-06-30 $
 * $Id: poll.php  www.mvmmall.com$
 * ---------------------------------------------
*/

require_once './include/common.inc.php';

if ($action=='view'){
	$poll       = $db->get_one("SELECT * FROM `{$tablepre}poll_table` ORDER BY end_date DESC LIMIT 0,1");
	$sum_poll   = $poll['statistics_answer1'] + $poll['statistics_answer2'] + $poll['statistics_answer3'] + $poll['statistics_answer4'];
	$sum_poll   = $sum_poll + $poll['statistics_answer5'] + $poll['statistics_answer6'] + $poll['statistics_answer7'];
	$sum_poll   = $sum_poll + $poll['statistics_answer8'] + $poll['statistics_answer9'] + $poll['statistics_answer10'];
	$temp_sdate = date($mm_date_format,$poll['start_date']);
	$start_bit  = explode("-",$temp_sdate);
	$temp_ddate = date($mm_date_format,$poll['end_date']);
	$end_bit    = explode("-",$temp_ddate);
	$view_vote  = "$lang[vote_date] : ".date($mm_time_format,$poll['start_date'])." $lang[vote_start] ~ ".date($mm_time_format,$poll['end_date']).$lang['vote_end'];
	$navigation = make_navigation($lang['vote_result'],GetBaseUrl('poll',$action));//导航
	require_once MVMMALL_ROOT.'header.php';
	require_once template('poll');
	footer();

} elseif ($action='vote') {
	$list = $db->get_one("SELECT * FROM `{$tablepre}poll_table` ORDER BY end_date DESC LIMIT 0,1");
	$list['start_date'] > $m_now_time && show_msg($lang['poll_start'],'close');
	$list['end_date'] < $m_now_time   &&  show_msg($lang['poll_end'],'close');
	if(empty($m_check_vote)){
		$temp_st = 'statistics_answer'.$num;
		$db->query("UPDATE `{$tablepre}poll_table` SET $temp_st = $temp_st + 1 WHERE uid='$list[uid]'");
		$_SESSION['mvm_sess_vote'] = $m_user_ip;
		show_msg('poll_participation','poll.php?action=view');
	}else {
		show_msg('poll_second_time','poll.php?action=view');
	}
} else {
	show_msg('pass_worng');
}